package Student;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.util.Random;

public class number3 { 
	public static void main(String[] args) throws Exception {
		FileInputStream fis = new FileInputStream("value.txt");
		int value = fis.read();
		Random random = new Random();
		int num = random.nextInt(100) + 1;
		String line = readLineFromFile("names.txt", num);
		if(value%2 == 0) {//
			System.out.println("第"+(value-'0')+"次点名，恭喜抽到 "+line);
			FileOutputStream fos=new FileOutputStream(new File("value.txt"));
			value++;
			fos.write((char)value);
		}else {
			System.out.println("第"+(value-'0')+"次点名，恭喜抽到 张三-男-23");
			FileOutputStream fos=new FileOutputStream(new File("value.txt"));
			value++;
			fos.write((char)value); 
		}
		fis.close();
	}

	public static String readLineFromFile(String fileName, int lineNumber) throws Exception {
		BufferedReader reader = new BufferedReader(new FileReader(fileName));
		String line;
		int currentLineNumber = 1;
		while ((line = reader.readLine()) != null) {
			if (currentLineNumber == lineNumber) {
				return line;
			}
			currentLineNumber++;
		}
		return null;
	}
}
 
